package com.gibs.peixunapi.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.gibs.peixunapi.model.TestPaper;

@Repository
public interface TestPaperDao extends JpaRepository<TestPaper, Integer>, JpaSpecificationExecutor<TestPaper> {

	@Query("from TestPaper where radioCount = ?1")
	List<TestPaper> find(String name);

	@Query("from TestPaper where radioCount like ?1")
	List<TestPaper> findLike(String name);

	@Query(value = "select * from TestPaper limit ?, ?", nativeQuery = true)
	List<TestPaper> findPage(Integer offset, Integer size);

	@Query(value = "select * from TestPaper where radioCount = ? limit ?, ?", nativeQuery = true)
	List<TestPaper> findPage(String name, Integer offset, Integer size);

	@Query(value = "select * from TestPaper where radioCount like ? limit ?, ?", nativeQuery = true)
	List<TestPaper> findPageLike(String name, Integer offset, Integer size);

	@Query(value = "select count(*) from TestPaper where radioCount = ?", nativeQuery = true)
	Long count(String name);

	@Query(value = "select count(*) from TestPaper where radioCount like ?", nativeQuery = true)
	Long countLike(String name);
	
	@Query("from TestPaper order by id asc")
	List<TestPaper> findAllAsc();
}

